package demo1;

    class A implements Cloneable{

        public int Cat=4;

        @Override
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        }
    }


    public class Person implements Cloneable {

        public String name1;
        public int age;
        public double score;

        public A tem = new A();


        public Person(String name, int age, double score) {
            this.name1 = name;
            this.age = age;
            this.score = score;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name1 + '\'' +
                    ", age=" + age +
                    ", score=" + score +
                    '}';
        }

        @Override
        protected Object clone() throws CloneNotSupportedException {
//            Person p=(Person)super.clone();
//            p.tem=(A)this.tem.clone();
//            return p;
            Person p = (Person) super.clone();

           p.tem=(A)this.tem.clone();

            return p;

        }
    }
